package com.caijinbang.study.entity;

import com.alibaba.fastjson.annotation.JSONField;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * 日志记录表
 *
 * @author caijb
 * @version 1.0.0
 * @date 2018-04-22 22:00
 */
@Table(name = "log_info")
@Entity
public class LogInfo implements Serializable {

    /**
     * 日志id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 客户端ip
     */
    @Column(name = "client_ip")
    private String clientIp;

    /**
     * 请求url
     */
    @Column(name = "url")
    private String url;

    /**
     * 请求类型,post,get,delete
     */
    @Column(name = "type")
    private String type;

    /**
     * 请求方法
     */
    @Column(name = "method")
    private String method;

    /**
     * 请求参数
     */
    @Column(name = "param_data")
    private String paramData;

    /**
     * sessionId
     */
    @Column(name = "session_id")
    private String sessionId;

    /**
     * 请求时间
     */
    @Column(name = "time")
    private Date time;

    /**
     * 相应时间
     */
    @Column(name = "return_time")
    private Date returnTime;

    /**
     * 响应数据
     */
    @Column(name = "return_data")
    private String returnData;

    /**
     * http响应码
     */
    @Column(name = "http_status")
    private String httpStatus;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getClientIp() {
        return clientIp;
    }

    public void setClientIp(String clientIp) {
        this.clientIp = clientIp;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getParamData() {
        return paramData;
    }

    public void setParamData(String paramData) {
        this.paramData = paramData;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    public Date getReturnTime() {
        return returnTime;
    }

    public void setReturnTime(Date returnTime) {
        this.returnTime = returnTime;
    }

    public String getReturnData() {
        return returnData;
    }

    public void setReturnData(String returnData) {
        this.returnData = returnData;
    }

    public String getHttpStatus() {
        return httpStatus;
    }

    public void setHttpStatus(String httpStatus) {
        this.httpStatus = httpStatus;
    }

    @Override
    public String toString() {
        return "LogInfo{" +
                "id=" + id +
                ", clientIp='" + clientIp + '\'' +
                ", url='" + url + '\'' +
                ", type='" + type + '\'' +
                ", method='" + method + '\'' +
                ", paramData='" + paramData + '\'' +
                ", sessionId='" + sessionId + '\'' +
                ", time=" + time +
                ", returnTime=" + returnTime +
                ", returnData='" + returnData + '\'' +
                ", httpStatus='" + httpStatus + '\'' +
                '}';
    }
}
